import * as typegoose from '@midwayjs/typegoose';
import { DB_NAME } from '../constants';

const mongo = {
  dbName: DB_NAME,
  replicaset: 'rs0',
  nodes: [
    '12.1.2.3:27017',
    '13.1.2.4:27017',
    '12.1.2.5:27017',
    '12.1.2.6:27017',
    '12.1.2.7:27017',
    '12.1.2.8:27017'
  ],
  dsn: {
    user: 'hully',
    password: 'hully',
    host: 'mongo.database.svc.cluster.local',
    replicaset: 'rs.k8s'
  }
};
const uri = `mongodb://${mongo.dsn.user}:${mongo.dsn.password}@${mongo.dsn.host}/${mongo.dbName}?replicaSet=${mongo.dsn.replicaset}`;

export const mongoose: typegoose.DefaultConfig = {
  uri,
  options: {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    dbName: mongo.dbName
  }
};